﻿using SQLite;
using System;
using System.Collections.Generic;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YellowMap.Resources;

namespace YellowMap
{
    public class AppModel
    {
        public  LanguageModel LanguageModel { get; set; }
        public  SettingModel SettingModel { get; set; }

        #region Singleton
        AppModel _instance = null;
        public AppModel Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new AppModel();
                }

                return _instance;
            }
        } 
        #endregion


        public static void Init()
        {
            CreateDatabase();
        }

        public static async void CreateDatabase()
        {
            IsolatedStorageFile isFile = IsolatedStorageFile.GetUserStoreForApplication();
            if (isFile.FileExists(Constant.DB_NAME))
                return;
            SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Constant.DB_NAME);
            await conn.CreateTableAsync<History>();
        }
    }
}
